package streamforce.crypto.policies;

import java.io.FileInputStream;
import java.util.Properties;

import streamforce.crypto.KPAbe;
import streamforce.crypto.event.TransformedCTEventAll;
import streamforce.crypto.event.TransformedCTEventAllAgg3;
import streamforce.crypto.event.TransformedCTEventJoin;

/**
 * Dummy interface, representing all policies. Classes implementing this
 * interface are subscribers to the query results.
 */
public class Policy {
	protected KPAbe cryptoHandler=null;
	public KPAbe getCryptoHandler() {
		return cryptoHandler;
	}

	public void setCryptoHandler(KPAbe cryptoHandler) {
		this.cryptoHandler = cryptoHandler;
	}

	protected int streamId, userId;
	public Policy(KPAbe cryptoHandler){		
		this.cryptoHandler = cryptoHandler; 
	}
	
	//initialize the cloud for transformation
	public void initACInstance(int streamId, int userId, byte[] pubK, byte[] transformK, byte[] detK){			
		this.streamId = streamId;
		this.userId = userId;
		this.cryptoHandler.initACInstance(pubK, streamId, transformK, userId, detK);
	}
	
	//initialize user for decryption
	public void initUser_simple(int userId, int columnId, byte[] pubK, byte[] tK, byte[] decK, byte[] detK){
		this.userId = userId;
		this.cryptoHandler.initUser_simple(userId, columnId, pubK, tK, decK, detK);
	}
	
	public void initUser_slidingWindow_Aggregate1(int userId, byte[] pubK, byte[] tK,
			byte[] decK, int windowSize, byte[] windowKey){
		this.userId = userId;
		this.cryptoHandler.initUser_slidingWindow_Aggregate1(this.userId, pubK, tK, decK, windowSize, windowKey);
	}
	
	public byte[] getJoiningKey(int id1, int id2){
		return this.cryptoHandler.getJoiningKey(id1, id2);
	}
	
	public void update(TransformedCTEventAll event){
		
	}
	
	public void update(TransformedCTEventJoin event){
		
	}
	
	public void update(TransformedCTEventAllAgg3 event){
		
	}
}
